import React, { useEffect } from "react";
import { useNavigate } from "react-router-dom";
import { useDispatch, useSelector } from "react-redux";
import { patientList, patientlist } from "store/Lzk_Store/Patint";
import "./index.scss";

const Index = ({ id }: { id: any }) => {
  const navigate = useNavigate();
  const dispatch = useDispatch<any>();
  const List = useSelector(patientlist);
  // console.log(List);

  interface liststyle {
    departmentId: any;
    page: number;
    count: number;
  }

  useEffect(() => {
    const data = {
      departmentId: id,
      page: 2,
      count: 5,
    };
    dispatch(patientList(data));
  }, [dispatch, id]);

  const nav = () => {
    navigate(`/suggestion/${id}`);
  };

  return (
    <div className="tabsList">
      {(List || []).map((item: any, index: any) => {
        return (
          <div key={index} className="List-item" onClick={nav}>
            <div className="List-txt">{item.title}</div>
            <div>{item.detail}</div>
            <div className="List-time">
              <span></span>
              <span>{item.releaseTime}</span>
            </div>
          </div>
        );
      })}
    </div>
  );
};
export default Index;
